package com.woniuxy.meal.common;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class RedisKey {

    /**
     * 验证码键
     */
    public static String getSendRegCodeKey(String phone) throws Exception{
        return "sendregcode:phone:"+phone;
    }

    /**
     * 一分钟内只能发送一次
     */
    public static String getSendRegCodeInMinKey(String phone) throws Exception{
        return "sendregcodeinmin:phone:"+phone;
    }

    /**
     * 一小时内验证码发送次数
     */
    public static String getSendRegCodeInHourKey(String phone) throws Exception{
        return "sendregcodeinhour:phone:"+phone;
    }


    /**
     * 一小时内密码输入错误次数
     */
    public static String getInputPwdInHourKey(String email) throws Exception{
        return "inputpwdinhour:email:"+email;
    }

    /**
     * 注册时手机号码锁
     */
    public static String getPhoneKey(String phone) throws Exception{
        return "register:phone:"+phone;
    }

    /**
     * 注册时用户名锁
     */
    public static String getEmailKey(String email) throws Exception{
        return "register:email:"+email;
    }

    /**
     * 用户默认地址
     */
    public static String getDefaultAddr(Integer userId){
        return "address:default:userid:"+userId;
    }

    /**
     *所有书籍类型
     * @return
     */
    public static String getFoodTypeTreeKey() {
        return "food:foodtype:tree";
    }

    /**
     * 每个用户的购物车键
     */
    public static String getUserCartKey(Long userId) {
        return "usercart:userid:"+userId;
    }
    /**
     * 每条购物车信息键
     */
    public static String getCartInfoKey(Long foodId) {
        return "cartinfo:foodid:"+foodId;
    }

    /**
     * 每个商铺的当月的总销量
     */
    public static String getStoreSaleKey(){
        LocalDate localDate = LocalDate.now();
        String dateStr = localDate.format(DateTimeFormatter.ofPattern("yyyy年MM月"));

        return "storesale:month:"+ dateStr;
    }

    /**
     * 商铺中每种食品的当月销量（只存当月的）
     */
    public static String getFoodSaleKey(){
        LocalDate localDate = LocalDate.now();
        String dateStr = localDate.format(DateTimeFormatter.ofPattern("yyyy年MM月"));
        return "foodsale:month:"+dateStr;
    }
    /**
     * 商家的总评分
     */
    public static String getStoreResultScore(Long storeId){return "resultscore:storescore:"+storeId;}
    /**
     * 菜品的总评分
     */
    public static String getFoodResultScore(Long foodId){return "resultscore:foodscore:"+foodId;}

    /**
     * 配送的总评分
     *
     */
    public static String getDphResultScore(Long storeId){return "resultscore:dphscore:"+storeId;}

    /**
     * 一个商铺的总评论次数
     *
     */
    public static String getCommentCount(Long storeId){return "commentcount:storeId:"+storeId;}



}
